package com.pktechan.api.config;

import com.pktechan.api.interceptor.CommonInterceptor;
import com.pktechan.api.interceptor.OperateLogInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: cloudfloating
 * @description: 通过实现WebMvcConfigurer注册拦截器
 * @author: qx.zhang
 * @create: 2021-03-19 10:14
 **/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Bean
    public CommonInterceptor commonInterceptor(){
        return new CommonInterceptor();
    }

    @Bean
    public OperateLogInterceptor operateLogInterceptor(){
        return new OperateLogInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(operateLogInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(commonInterceptor()).addPathPatterns("/**").excludePathPatterns("/*","/css/*","/font/*","/images/*","/js/*","/*.html","/*.ttf","/*.txt","/miniProgramController/*","/wxPayController/notify","/wxPayController/refundNotify","/sendMessageController/sendSubscribeMessage");
    }
}
